<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Article {
        constructor(title, date) {
          this.title = title
          this.date = date
        }

        static compare(articleA, articleB) {
          return articleA.date - articleB.date
        }
      }

      // 用法
      let articles = [
        new Article('HTML', new Date(2019, 1, 1)),
        new Article('CSS', new Date(2019, 0, 1)),
        new Article('JavaScript', new Date(2019, 11, 1)),
      ]

      articles.sort(Article.compare)  // 根据时间排序
      // console.log(articles)

      console.log(articles[0].title)
    </script>
  </body>
</html>
